package com.lc202309;

/**
 * Description:
 *
 * @Create 2023/9/7 22:59
 * @Version 1.0
 */
public class Solution121 {
    public int maxProfit(int[] prices) {
        int res = 0;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < prices.length; i++) {

            min = Math.min(prices[i], min);
            res = Math.max(res, prices[i] - min);
        }
        return res;
    }
}
